package top.coolrainly.module.pb.dal.mysql.user;

import java.util.*;

import top.coolrainly.framework.common.pojo.PageResult;
import top.coolrainly.framework.mybatis.core.query.LambdaQueryWrapperX;
import top.coolrainly.framework.mybatis.core.mapper.BaseMapperX;
import top.coolrainly.module.pb.dal.dataobject.user.MemberUserDO;
import org.apache.ibatis.annotations.Mapper;
import top.coolrainly.module.pb.controller.admin.user.vo.*;

/**
 * 用户信息 Mapper
 *
 * @author CoolRainLy
 */
@Mapper
public interface MemberUserMapper extends BaseMapperX<MemberUserDO> {
    default MemberUserDO selectByUsername(String username) {
        return selectOne(MemberUserDO::getUsername, username);
    }

    default PageResult<MemberUserDO> selectPage(MemberUserPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<MemberUserDO>()
                .eqIfPresent(MemberUserDO::getOrgId, reqVO.getOrgId())
                .likeIfPresent(MemberUserDO::getUsername, reqVO.getUsername())
                .betweenIfPresent(MemberUserDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(MemberUserDO::getId));
    }

}